package top.kaoshanji.p1ch05b.main;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import top.kaoshanji.p1ch05b.config.ProjectConfig;
import top.kaoshanji.p1ch05b.services.CommentService;
import top.kaoshanji.p1ch05b.services.UserService;

/**
 * 代码清单-p1ch05b-95页a：测试Spring在Main类中注入单例bean的行为
 * @author kaoshanji
 * ^_^
 * create time 2025/4/27 20:19
 */
public class Main {

    public static void main(String[] args) {

        var context = new AnnotationConfigApplicationContext(ProjectConfig.class);

        var s1 = context.getBean(CommentService.class);
        var s2 = context.getBean(UserService.class);

        System.out.println(s1.getCommentRepository() == s2.getCommentRepository());

    }

}
